<?php

namespace App\Repositories\Stock;

use App\Models\Stock\ProductStockLog;
use App\Repositories\BaseRepository;

class ProductStockLogRepository extends BaseRepository
{

    public function __construct(ProductStockLog $model)
    {
        parent::__construct($model);
    }

    public function getList($columns = ['*'], $where = [], $page = 1, $limit = 15, $sort = 'created_at', $order = 'desc'): \Illuminate\Contracts\Pagination\LengthAwarePaginator
    {
        $this->condition = array_merge($this->condition, $where);
        return $this->model->with(['product' => function ($query) {
            $query->select('id', 'name');
        }, 'storage' => function ($query) {
            $query->select('id', 'name');
        }])->where($this->condition)
            ->orderBy($sort, $order)
            ->paginate($limit, $columns, 'page', $page);
    }

}